#ifndef	_GLES2_TEXTURE_H_
#define _GLES2_TEXTURE_H_

#include "image/Image.h"


namespace easy2d {


	class GLES2Texture : public ITexture
	{
	public:
		GLES2Texture();
		virtual ~GLES2Texture();

		virtual bool initialize(Image& image);
		virtual bool initialize(uint width, uint height, EPixelFormat format, uint color);
		virtual void cleanup();
		virtual bool isValid();
		
		virtual int width();
		virtual int height();
		virtual void bind(int pass);

		virtual int videoMemory();

		virtual void* lock(const Rect* lockRect);
		virtual void unlock();
		virtual bool isLocked();

		virtual void upateRenderTime();
		virtual uint getRenderTime();

		void setRenderToTexture();

	protected:
		void getFormat(EPixelFormat pixelFormat, uint &nInternalPixelFormat, uint &nFormat, uint& nNumElemBytes, uint& nType);

	protected:
		GLuint mFrameBufferId;
		GLuint mTexId;
		int mWidth;
		int mHeight;

		bool mIsCompressed;
		int mCompressedSize;
		byte* mBuffer;
		uint mPixelFormat;
		uint mNumElemBytes;
		uint mLockDataSize;
		Rect mLockRect;
		bool mLock;

		long mLastRenderTime;
	};




}	// namespace


#endif